package main

import (
	"fmt"
	"time"

	"gitee.com/gousing/cache"
)

func main() {
	local, err := cache.NewMemory(&cache.MemoryOptions{
		DefaultExpire: time.Minute * 30,
	})
	if err != nil {
		fmt.Println(err)
		return
	}
	remote, err := cache.NewRedis(&cache.RedisOptions{
		DefaultExpire: time.Hour,
	})
	if err != nil {
		fmt.Println(err)
		return
	}
	myCache, err := cache.NewL2Cache(local, remote, nil)
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(myCache.DefaultExpire())
	myCache.Set("key1", "key1 string value")
	fmt.Println(myCache.Get("key1"))
	fmt.Println(myCache.TTL("key1"))
	myCache.Expire("key1", time.Minute)
	fmt.Println(myCache.TTL("key1"))
	myCache.Delete("key1")
	fmt.Println(myCache.Get("key1"))
}
